package java3_30;

import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * 输入一个目录，输出其中所有的文件名(递归和非递归方法)
 */
public class Homework6 {
    public static void main(String[] args) {
        String path = "G:\\JAVA84";
        print(path);
    }

    public static void print(String fatherPath){
        File father = new File(fatherPath);
        if (father.exists()&&father.isDirectory()){
            String[] list = father.list();
            String[] child = list;
            for (String path2:child) {
                String path3 = fatherPath +"\\"+path2;
                File file = new File(path3);
                if (!file.isDirectory()){
                    System.out.println(file.getName());
                }else {
                    print(path3);
                    System.out.println(file.getName());
                }
            }
        }
    }

}
